﻿namespace MSSqlSchemaDoc.Core.DataStructures
{
    using System.Collections.ObjectModel;
    using System.Xml.Serialization;

    /// <summary>
    /// Represents an index.
    /// </summary>
    public class Index
    {
        /// <summary>
        /// Gets or sets the name of the index.
        /// </summary>
        [XmlAttribute()]
        public string Name { get; set; }

        /// <summary>
        /// Gets or sets the type of the index.
        /// </summary>
        [XmlAttribute()]
        public string IndexType { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether the index is a unique index.
        /// </summary>
        [XmlElement()]
        public bool IsUnique { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether the duplicate keys are ignored.
        /// </summary>
        [XmlElement()]
        public bool IgnoreDuplicateKey { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether the index is the primary key index.
        /// </summary>
        [XmlElement()]
        public bool IsPrimaryKey { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether the index is a unique contraint index.
        /// </summary>
        [XmlElement()]
        public bool IsUniqueConstraint { get; set; }

        /// <summary>
        /// Gets or sets the fill factor of the index.
        /// </summary>
        [XmlElement()]
        public int FillFactor { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether the index is padded.
        /// </summary>
        [XmlElement()]
        public bool IsPadded { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether the index is disabled.
        /// </summary>
        [XmlElement()]
        public bool IsDisabled { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether the index is hypothetical.
        /// </summary>
        [XmlElement()]
        public bool IsHypothetical { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether the index allows row locks.
        /// </summary>
        [XmlElement()]
        public bool AllowRowLocks { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether the index allows row locks.
        /// </summary>
        [XmlElement()]
        public bool AllowPageLocks { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether the index has a filter.
        /// </summary>
        [XmlElement()]
        public bool HasFilter { get; set; }

        /// <summary>
        /// Gets or sets the filter definition.
        /// </summary>
        [XmlElement()]
        public string FilterDefinition { get; set; }

        /// <summary>
        /// Gets or sets the columns which forms part of the index.
        /// </summary>
        [XmlArray()]
        public Collection<IndexColumn> Columns { get; set; }
    }
}
